package com.cskaoyan.bean.vo;

import com.cskaoyan.bean.po.CommentPO;
import com.cskaoyan.util.StringToArrayUtils;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author by WANGJun
 * @date 2022/6/6 9:22
 */
@NoArgsConstructor
@Data
public class CommentVO implements Serializable {

    /**
     * id : 1082
     * valueId : 274
     * type : 1
     * content : qqqqqq
     * adminContent : 地方撒时代付
     * userId : 1
     * hasPicture : false
     * picUrls : []
     * star : 5
     * addTime : 2022-05-10 23:03:34
     * updateTime : 2022-05-10 23:03:34
     * deleted : false
     */

    private int id;
    private int valueId;
    private int type;
    private String content;
    private String adminContent;
    private int userId;
    private boolean hasPicture;
    private int star;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date addTime;
    private Date updateTime;
    private boolean deleted;
    private List<String> picUrls;

    public static CommentVO setCommentVO(CommentPO commentPO){
        CommentVO vo = new CommentVO();
        vo.id = commentPO.getId();
        vo.valueId = commentPO.getValueId();
        vo.type = commentPO.getType();
        vo.content = commentPO.getContent();
        vo.adminContent = commentPO.getAdminContent();
        vo.userId = commentPO.getUserId();
        vo.hasPicture = commentPO.getHasPicture();
        vo.star = commentPO.getStar();
        vo.addTime = commentPO.getAddTime();
        vo.updateTime = commentPO.getUpdateTime();
        vo.deleted = commentPO.isDeleted();
        System.out.println("urls:"+commentPO.getPicUrls());
        vo.picUrls = StringToArrayUtils.toArray(commentPO.getPicUrls(),String.class);
        System.out.println("vo:"+vo.picUrls);
        return vo;
    }
}
